<template></template>
<script>
  import {toLngLat} from '../utils/convert-helper';
  import registerMixin from '../mixins/register-component';
  export default {
    name: 'el-bmap-ground-overlay',
    mixins: [registerMixin],
    props: [
      'vid',
      'opacity',
      'url',
      'bounds',
      'minLevel',
      'maxLevel',
      'events',
      'onceEvents'
    ],
    data() {
      return {
        propsRedirect: {
          minLevel: 'displayOnMinLevel',
          maxLevel: 'displayOnMaxLevel',
          url: 'imageURL'
        },
        converters: {
          bounds(arr) {
            return new BMapGL.Bounds(toLngLat(arr[0]), toLngLat(arr[1]));
          }
        },
        handlers: {
        }
      };
    },
    methods: {
      __initComponent(options) {
        this.$bmapComponent = new BMapGL.GroundOverlay(options.bounds, options);
        options.map.addOverlay(this.$bmapComponent);
      }
    },
    destroyed() {
      if (this.$bmapComponent && this.$bmapComponent.getMap()) {
        this.$bmapComponent.getMap().removeOverlay(this.$bmapComponent);
      }
    }
  };
</script>
